version: "3.8"

services:
  drone:
    image: drone/drone:2.0.0 #不要用latest,latest并非稳定版本
    ports:
      - "7000:80"
    networks:
      - "drone"
    volumes:
      - /data/drone/:/var/lib/drone/:rw
      - /var/run/docker.sock:/var/run/docker.sock:rw
    environment:
      #- "DB_PASSWD_FILE=/run/secrets/db_passwd"
      - DRONE_DEBUG=true
      - DRONE_DATABASE_DATASOURCE=drone:123456@tcp(10.0.12.4:3306)/drone?parseTime=true #mysql配置，要与上边mysql容器中的配置一致
      - DRONE_DATABASE_DRIVER=mysql
      - DRONE_GITEA_SKIP_VERIFY=false
      - DRONE_GITEA_CLIENT_ID=688c8b98-b7c6-4174-a824-10993bd554ad
      - DRONE_GITEA_CLIENT_SECRET=P9cBOy2ehCtkRBEn8r7sfFUsnwS9TOQA2RQMDee3gb75
      - DRONE_GITEA_SERVER=http://43.138.195.10:3000/
      - DRONE_TLS_AUTOCERT=false
      - DRONE_RUNNER_CAPACITY=2
      - DRONE_RPC_SECRET=48f11fe546a25099cde4a05ce35a4815 #RPC秘钥
      - DRONE_SERVER_PROTO=http #这个配置决定了你激活时仓库中的webhook地址的proto
      - DRONE_SERVER_HOST=43.138.195.10:7000
      - DRONE_USER_CREATE=username:root,admin:true #管理员账号，是你想要作为管理员的Gitea用户名
      - DRONE_USER_FILTER=root
      - DRONE_DATADOG_ENABLE=false
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role == manager]
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 120s
  drone-runner:
    image: drone/drone-runner-docker:1.6.3
    networks:
      - "drone"
    depends_on:
      - drone
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:rw
    environment:
      - DRONE_RPC_HOST=43.138.195.10:7000
      - DRONE_RPC_SECRET=48f11fe546a25099cde4a05ce35a4815
      - DRONE_RPC_PROTO=http
      - DRONE_RUNNER_CAPACITY=1
      - DRONE_RUNNER_NAME=runner
      #- DRONE_RUNNER_LABELS=machine1:runner1
      - DRONE_DEBUG=true
      - DRONE_LOGS_DEBUG=true
      - DRONE_LOGS_PRETTY=true
      - DRONE_LOGS_NOCOLOR=false
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role == manager]
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 120s
networks:
  drone:
    external: true
    name: traefik_default

